<script> alert 不跳转

来源:百度知道 编辑:UC知道 时间:2024/06/15 01:47:46
if (txtBCode.Text == "")
{
Response.Write("<script>alert('The BarCode can't be null.');</script>");
return;
}
这种Alert如何能实现激发时不跳转到下一个页面,直接在本页画面就出现Alert对话框啊?谢谢!
(目前运行结果是激发条件时总会跳转到背景空白页然后点击确定之后回来。。)
为什么我使用Page.RegisterStartupScript的方法

提示错误 CS1501: “RegisterStartupScript”方法没有采用“1”个参数的重载 啊

不太可能吧?跳到别的页?怎么会呢...是页面的样式改变了吧?
用这个不会改变样式的:
if (txtBCode.Text == "")
{
this.Page.RegisterStartupScript("msg","<script>alert('The BarCode can't be null.')</script>");

}

Response.Write就是这样,不过不是跳转

RegisterStartupScript("", "<script>alert(''The BarCode can't be null.');</script>");

alert('The BarCode can't be null.');</script>
哪来的分号?
去掉分号就行了老大!以后仔细点

这个需要写一个客户端的script
function isNull()
{
if (document.getElementById('txtBCode').value=="")
{
alert('the barcode can't be null')
return;
}
}
比如点击button的时候触发,就设置buton属性的onclientclick="isNull()"

Response.Write输出的东西在源代码前面


ClientScript.RegisterStartupScript(this.GetType(), "aa", "alert(''The BarCode can